clove/pkviewer
web/src/routes/manage/[systemId]/+layout.server.ts
back to web/src/routes/manage/[systemId]
/* web/src/routes/manage/[systemId]/+layout.server.ts */
import type { LayoutServerLoad } from "./$types";
import { manageApi, seg } from "$lib/server/api.ts";
import type { SystemOverview } from "$lib/types.ts";
/**
* Loading the system doubles as the authorization check. It does not 404 here:
* each page does, so the not-found renders with the right status.
*/
export const load: LayoutServerLoad = async ({ params }) => {
const result = await manageApi.get<SystemOverview>(`/manage/systems/${seg(params.systemId)}`);
return { system: result.ok ? result.value : null };
};